View Javadoc

1   /*$Id$
2    * Created on 21-Jun-2005
3    *
4    * Copyright (C) AstroGrid. All rights reserved.
5    *
6    * This software is published under the terms of the AstroGrid 
7    * Software License version 1.2, a copy of which has been included 
8    * with this distribution in the LICENSE.txt file.  
9    *
10  **/
11  package org.votech.ds6.plastlets;
12  
13  import org.apache.commons.logging.Log;
14  import org.apache.commons.logging.LogFactory;
15  
16  /*** Check that the JDIC system browser is available.
17   * @author Noel Winstanley nw@jb.man.ac.uk 21-Jun-2005
18   * @author canabalised by jdt@roe.ac.uk april 2006
19   *
20   */
21  public class CheckJDICPresent implements Check {
22      /***
23       * Commons Logger for this class
24       */
25      private static final Log logger = LogFactory.getLog(CheckJDICPresent.class);
26  
27      
28      public final static GeneralClassPresentCheck systemTray = new GeneralClassPresentCheck("org.jdesktop.jdic.tray.SystemTray");
29      public final static GeneralClassPresentCheck browser = new GeneralClassPresentCheck("org.jdesktop.jdic.browser.WebBrowser");
30      public final static GeneralClassPresentCheck desktop = new GeneralClassPresentCheck("org.jdesktop.jdic.desktop.Desktop");
31  
32      /***
33       * Check them all
34       */
35  	public boolean check() {
36  		return systemTray.check() && browser.check() && desktop.check();
37  	}
38  	
39      public static class GeneralClassPresentCheck implements Check  {
40      	private String clazz;
41  		public GeneralClassPresentCheck(String className) {
42      		this.clazz = className;
43      	}
44          public boolean check() {
45              try {
46                  logger.info("Checking for class "+clazz);
47                  Class jdic = Class.forName(clazz);
48                  if (jdic != null) {
49                      return true;
50                      }        
51              } catch (NoClassDefFoundError e) {
52                  logger.info("Class not present");            
53              } catch (ClassNotFoundException e) {            
54                  logger.info("Class not present");
55              } catch (UnsatisfiedLinkError e) {
56              	//TODO doesn't work - this only gets found out when the class is used.
57                  logger.info("Class present, but binary libraries are not.");
58              }
59              return false;
60          }    	
61      }
62  
63  
64  
65  
66  
67  }
68  
69  
70  /* 
71  $Log$
72  Revision 1.1  2006/04/17 21:28:20  jdt
73  rename of folders
74  
75  Revision 1.2  2006/04/17 21:24:53  jdt
76  polished up plastlets
77  
78  Revision 1.1  2006/04/17 14:28:38  jdt
79  disentangnled a bit
80  
81  Revision 1.1  2005/08/11 10:15:00  nw
82  finished split
83  
84  Revision 1.2  2005/08/05 11:46:55  nw
85  reimplemented acr interfaces, added system tests.
86  
87  Revision 1.1  2005/06/23 09:08:26  nw
88  changes for 1.0.3 release
89  
90  Revision 1.1  2005/06/22 08:48:52  nw
91  latest changes - for 1.0.3-beta-1
92   
93  */